/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package homework.demo04;

/**
 *
 * 2010404106范艺馨
 */
public class ID {
    public static void main(String[] args) {
        String mobile = "45033119910807001X";
        boolean flag = true;
        if (mobile.length()!=18) {
            flag = false;
                    }
        if (!(mobile.startsWith("45"))) {
            flag = false;
        }
        String numstr = "0123456789";
        for (int i = 0; i < mobile.length()-1; i++) {
            char c = mobile.charAt(i);
            int temp = numstr.indexOf(c);
            if (temp<0) {
                flag = false;
                break;
            }
        }
        String numstr1 = "01234567890X";
        for (int i = 0; i < mobile.length(); i++) {
            char c = mobile.charAt(17);
            int temp = numstr1.indexOf(c);
            if (temp<0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            System.out.println("身份证合法");
        }else{
            System.out.println("身份证不合法");
        }
    }

}
